﻿using Application.Allot_dService;
using Application.Check_dService;
using Domain.Entity;
using Domain.Entity.ic;
using Domain.Entity.tr;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace WMSManage.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    [Authorize]//需要鉴权
    public class Check_dController : ControllerBase
    {
        private readonly ICheck_dService check_DService;

        public Check_dController(ICheck_dService check_DService)
        {
            this.check_DService = check_DService;
        }


        /// <summary>
        /// 查询盘点明细
        /// </summary>
        /// <param name="icid"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<Check_d>> GetCheck_Ds(int icid)
        {
            return await check_DService.GetCheck_Ds(icid);
        }


        /// <summary>
        /// 查询盘盈盘亏明细
        /// </summary>
        /// <param name="icid"></param>
        /// <param name="status"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<Check_d>> GetCheck_DsYingKui(int icid, string status)
        {
            return await check_DService.GetCheck_DsYingKui(icid,status);
        }

        /// <summary>
        /// 统计盘点
        /// </summary>
        /// <param name="CurrentPage"></param>
        /// <param name="proc_code"></param>
        /// <param name="ic_code"></param>
        /// <param name="ic_type"></param>
        /// <param name="create_name"></param>
        /// <param name="type_id"></param>
        /// <param name="proc_primary_unit"></param>
        /// <param name="wh_id"></param>
        /// <param name="ic_user"></param>
        /// <param name="createstartTime"></param>
        /// <param name="createendTime"></param>
        /// <param name="checkprofitNumMin"></param>
        /// <param name="checkprofitNumMax"></param>
        /// <param name="checklossesNumMin"></param>
        /// <param name="checklossesNumMax"></param>
        /// <param name="checkprofitTotalMin"></param>
        /// <param name="checkprofitTotalMax"></param>
        /// <param name="checklossesTotalMin"></param>
        /// <param name="checklossesTotalMax"></param>
        /// <param name="icStatusArray"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<FenYe<CheckTJResult>> GetCheckTJResult(int CurrentPage, string? proc_code, string? ic_code, string? ic_type, string? create_name, int? type_id, string? proc_primary_unit, int? wh_id, string? ic_user, string? createstartTime, string? createendTime, decimal? checkprofitNumMin, decimal? checkprofitNumMax, decimal? checklossesNumMin, decimal? checklossesNumMax, decimal? checkprofitTotalMin, decimal? checkprofitTotalMax, decimal? checklossesTotalMin, decimal? checklossesTotalMax, [FromQuery] int[]? icStatusArray)
        {
            FenYe<CheckTJResult> fenYe = new FenYe<CheckTJResult>()
            {
                CurrentPage = CurrentPage,
            };
            FenYe<CheckTJResult> allotTJResults = await check_DService.GetCheckTJResult(fenYe, proc_code,ic_code, ic_type, create_name, type_id, proc_primary_unit, wh_id, ic_user, createstartTime, createendTime, checkprofitNumMin, checkprofitNumMax, checklossesNumMin, checklossesNumMax, checkprofitTotalMin, checkprofitTotalMax, checklossesTotalMin, checklossesTotalMax, icStatusArray);
            return allotTJResults;
        }
    }
}
